import Editor from "../../editor"
import { InsertTextOperation } from "../../operations";

export default function withUpperCase (editor: Editor) {
  const apply = editor.apply.bind(editor);
  editor.apply = (operation) => {
    if (operation instanceof InsertTextOperation) {
      let spacers = operation.getSpacers().toUpperCase();
      operation.setSpacers(spacers);
    }
    apply(operation);
  }
  return editor;
}